Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Crate ntex_macros

Source
Expand description

ntex macros module

Generators for routes

§Route

Macros:

§Attributes:

  • "path" - Raw literal string with path for which to register handle. Mandatory.
  • guard = "function_name" - Registers function as guard using ntex::web::guard::fn_guard
  • error = "ErrorRenderer" - Register handler for specified error renderer

§Notes

Function name can be specified as any expression that is going to be accessible to the generate code (e.g my_guard or my_module::my_guard)

§Example:

use ntex::web::{get, Error, HttpResponse};
use futures::{future, Future};

#[get("/test")]
async fn async_test() -> Result<HttpResponse, Error> {
    Ok(HttpResponse::Ok().finish())
}

Attribute Macros§

rt_main
Marks async function to be executed by ntex system.
rt_test
Marks async test function to be executed by ntex runtime.
web_connect
Creates route handler with CONNECT method guard.
web_delete
Creates route handler with DELETE method guard.
web_get
Creates route handler with GET method guard.
web_head
Creates route handler with HEAD method guard.
web_options
Creates route handler with OPTIONS method guard.
web_patch
Creates route handler with PATCH method guard.
web_post
Creates route handler with POST method guard.
web_put
Creates route handler with PUT method guard.
web_trace
Creates route handler with TRACE method guard.